package com.hk.core.data.r2dbc.repository;

import com.hk.core.data.r2dbc.tenants.TenantR2dbcEntityTemplate;
import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
import org.springframework.data.r2dbc.core.ReactiveDataAccessStrategy;
import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.r2dbc.core.DatabaseClient;

/**
 * @author Kevin
 * @date 2024-04-20 22:13
 */
public class TenantR2dbcRepositoryFactory extends R2dbcRepositoryFactory {

    public TenantR2dbcRepositoryFactory(DatabaseClient databaseClient, ReactiveDataAccessStrategy dataAccessStrategy) {
        super(new TenantR2dbcEntityTemplate(new R2dbcEntityTemplate(databaseClient, dataAccessStrategy)));
    }

    public TenantR2dbcRepositoryFactory(R2dbcEntityOperations operations) {
        super(new TenantR2dbcEntityTemplate(operations));
    }

    @Override
    protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
        return BaseSimpleR2dbcRepository.class;
    }
}
